import type { Dishes,DishesSearchForm } from "./type";
import request from '@/util/request'
import type { Page } from "../types/page";

const API = '/dishes-service/dishes'

/* 分页 + 模糊查询 */
export const getDishesList = (searchForm:DishesSearchForm)=>{
    return request<Page<Dishes>,Page<Dishes>>({
        url:API + "/list",
        method:'GET',
        params:searchForm
    })
}

/* 添加菜品 */
export const addDishes = (dishes:Dishes)=>{
    return request<any,any,Dishes>({
        url: API,
        method: 'POST',
        data : dishes
    })
}


/* 添加菜品 */
export const updateDishes = (dishes:Dishes)=>{
    return request<any,any,Dishes>({
        url: `${API}/${dishes.id}`,
        method: 'PUT',
        data : dishes
    })
}
/* 刪除菜品 */
export const deleteDishes = (id:number)=>{
    return request({
        url:`${API}/${id}`,
        method:'DELETE'
    })
}